Add device-taking variants of begin_resize/move_drag
authorMatthias Clasen <mclasen@redhat.com>
Sat, 5 Nov 2011 05:10:16 +0000 (01:10 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 5 Nov 2011 05:10:16 +0000 (01:10 -0400)
This was one of the last places where display->core_pointer was
used in non-deprecated code paths.

gdk/gdk.symbols
gdk/gdkwindow.c
gdk/gdkwindow.h
gdk/gdkwindowimpl.h
gdk/x11/gdkwindow-x11.c

index 0a2a334332b1b6d5fbe633ce3ae4ab6bc0d37f59..15251e2b991c9e01a80ac96aaf6b662c44a3f809 100644 (file)
@@ -365,9 +365,11 @@ gdk_window_at_pointer
 gdk_window_attributes_type_get_type
 gdk_window_beep
 gdk_window_begin_move_drag
+gdk_window_begin_move_drag_for_device
 gdk_window_begin_paint_rect
 gdk_window_begin_paint_region
 gdk_window_begin_resize_drag
+gdk_window_begin_resize_drag_for_device
 gdk_window_window_class_get_type
 gdk_window_configure_finished
 gdk_window_constrain_size
index c8faa921cdabf1e3aacfc4aa33c8485294a98b16..e2966e2129e212519e99eeb7a2c4ea5ba93574d3 100644 (file)
@@ -10448,9 +10448,10 @@ gdk_window_set_functions (GdkWindow    *window,
 }
 
 /**
- * gdk_window_begin_resize_drag:
+ * gdk_window_begin_resize_drag_for_device:
  * @window: a toplevel #GdkWindow
  * @edge: the edge or corner from which the drag is started
+ * @device: the device used for the operation
  * @button: the button being used to drag
  * @root_x: root window X coordinate of mouse click that began the drag
  * @root_y: root window Y coordinate of mouse click that began the drag
@@ -10462,7 +10463,35 @@ gdk_window_set_functions (GdkWindow    *window,
  * with window managers that support the <ulink url="http://www.freedesktop.org/Standards/wm-spec">Extended Window Manager Hints</ulink>, but has a
  * fallback implementation for other window managers.
  *
- **/
+ * Since: 3.4
+ */
+void
+gdk_window_begin_resize_drag_for_device (GdkWindow     *window,
+                                         GdkWindowEdge  edge,
+                                         GdkDevice     *device,
+                                         gint           button,
+                                         gint           root_x,
+                                         gint           root_y,
+                                         guint32        timestamp)
+{
+  GDK_WINDOW_IMPL_GET_CLASS (window->impl)->begin_resize_drag (window, edge, device, button, root_x, root_y, timestamp);
+}
+
+/**
+ * gdk_window_begin_resize_drag:
+ * @window: a toplevel #GdkWindow
+ * @edge: the edge or corner from which the drag is started
+ * @button: the button being used to drag
+ * @root_x: root window X coordinate of mouse click that began the drag
+ * @root_y: root window Y coordinate of mouse click that began the drag
+ * @timestamp: timestamp of mouse click that began the drag (use gdk_event_get_time())
+ *
+ * Begins a window resize operation (for a toplevel window).
+ *
+ * This function assumes that the drag is controlled by the
+ * client pointer device, use gdk_window_begin_resize_drag_for_device()
+ * to begin a drag with a different device.
+ */
 void
 gdk_window_begin_resize_drag (GdkWindow     *window,
                               GdkWindowEdge  edge,
@@ -10471,25 +10500,59 @@ gdk_window_begin_resize_drag (GdkWindow     *window,
                               gint           root_y,
                               guint32        timestamp)
 {
-  GDK_WINDOW_IMPL_GET_CLASS (window->impl)->begin_resize_drag (window, edge, button, root_x, root_y, timestamp);
+  GdkDeviceManager *device_manager;
+  GdkDevice *device;
+
+  device_manager = gdk_display_get_device_manager (gdk_window_get_display (window));
+  device = gdk_device_manager_get_client_pointer (device_manager);
+  gdk_window_begin_resize_drag_for_device (window, edge,
+                                           device, button, root_x, root_y, timestamp);
 }
 
 /**
- * gdk_window_begin_move_drag:
+ * gdk_window_begin_move_drag_for_device:
  * @window: a toplevel #GdkWindow
+ * @device: the device used for the operation
  * @button: the button being used to drag
  * @root_x: root window X coordinate of mouse click that began the drag
  * @root_y: root window Y coordinate of mouse click that began the drag
  * @timestamp: timestamp of mouse click that began the drag
  *
- * Begins a window move operation (for a toplevel window).  You might
- * use this function to implement a "window move grip," for
+ * Begins a window move operation (for a toplevel window).
+ * You might use this function to implement a "window move grip," for
  * example. The function works best with window managers that support
  * the <ulink url="http://www.freedesktop.org/Standards/wm-spec">Extended
  * Window Manager Hints</ulink>, but has a fallback implementation for
  * other window managers.
  *
- **/
+ * Since: 3.4
+ */
+void
+gdk_window_begin_move_drag_for_device (GdkWindow *window,
+                                       GdkDevice *device,
+                                       gint       button,
+                                       gint       root_x,
+                                       gint       root_y,
+                                       guint32    timestamp)
+{
+  GDK_WINDOW_IMPL_GET_CLASS (window->impl)->begin_move_drag (window,
+                                                             device, button, root_x, root_y, timestamp);
+}
+
+/**
+ * gdk_window_begin_move_drag:
+ * @window: a toplevel #GdkWindow
+ * @button: the button being used to drag
+ * @root_x: root window X coordinate of mouse click that began the drag
+ * @root_y: root window Y coordinate of mouse click that began the drag
+ * @timestamp: timestamp of mouse click that began the drag
+ *
+ * Begins a window move operation (for a toplevel window).
+ *
+ * This function assumes that the drag is controlled by the
+ * client pointer device, use gdk_window_begin_move_drag_for_device()
+ * to begin a drag with a different device.
+ */
 void
 gdk_window_begin_move_drag (GdkWindow *window,
                             gint       button,
@@ -10497,7 +10560,12 @@ gdk_window_begin_move_drag (GdkWindow *window,
                             gint       root_y,
                             guint32    timestamp)
 {
-  GDK_WINDOW_IMPL_GET_CLASS (window->impl)->begin_move_drag (window, button, root_x, root_y, timestamp);
+  GdkDeviceManager *device_manager;
+  GdkDevice *device;
+
+  device_manager = gdk_display_get_device_manager (gdk_window_get_display (window));
+  device = gdk_device_manager_get_client_pointer (device_manager);
+  gdk_window_begin_move_drag_for_device (window, device, button, root_x, root_y, timestamp);
 }
 
 /**
index f50d84a79bcce371bb0cbe2eafc087bd413b434b..50779fe365619a12ffee76bd5828d0cde4085472 100644 (file)
@@ -784,19 +784,32 @@ void          gdk_window_register_dnd    (GdkWindow       *window);
 
 GdkDragProtocol
               gdk_window_get_drag_protocol(GdkWindow      *window,
-                                          GdkWindow      **target);
-
-void gdk_window_begin_resize_drag (GdkWindow     *window,
-                                   GdkWindowEdge  edge,
-                                   gint           button,
-                                   gint           root_x,
-                                   gint           root_y,
-                                   guint32        timestamp);
-void gdk_window_begin_move_drag   (GdkWindow     *window,
-                                   gint           button,
-                                   gint           root_x,
-                                   gint           root_y,
-                                   guint32        timestamp);
+                                           GdkWindow     **target);
+
+void gdk_window_begin_resize_drag            (GdkWindow     *window,
+                                              GdkWindowEdge  edge,
+                                              gint           button,
+                                              gint           root_x,
+                                              gint           root_y,
+                                              guint32        timestamp);
+void gdk_window_begin_resize_drag_for_device (GdkWindow     *window,
+                                              GdkWindowEdge  edge,
+                                              GdkDevice     *device,
+                                              gint           button,
+                                              gint           root_x,
+                                              gint           root_y,
+                                              guint32        timestamp);
+void gdk_window_begin_move_drag              (GdkWindow     *window,
+                                              gint           button,
+                                              gint           root_x,
+                                              gint           root_y,
+                                              guint32        timestamp);
+void gdk_window_begin_move_drag_for_device   (GdkWindow     *window,
+                                              GdkDevice     *device,
+                                              gint           button,
+                                              gint           root_x,
+                                              gint           root_y,
+                                              guint32        timestamp);
 
 /* Interface for dirty-region queueing */
 void       gdk_window_invalidate_rect           (GdkWindow          *window,
index e0888134562de2395ccae1b6bfe0ae6d1c7b79a2..bc7118ebfd489f55cd81ddaded40396d3538d8dd 100644 (file)
@@ -231,16 +231,18 @@ struct _GdkWindowImplClass
   void         (* set_functions)        (GdkWindow    *window,
                                         GdkWMFunction functions);
   void         (* begin_resize_drag)    (GdkWindow     *window,
-                                        GdkWindowEdge  edge,
-                                        gint           button,
-                                        gint           root_x,
-                                        gint           root_y,
-                                        guint32        timestamp);
+                                         GdkWindowEdge  edge,
+                                         GdkDevice     *device,
+                                         gint           button,
+                                         gint           root_x,
+                                         gint           root_y,
+                                         guint32        timestamp);
   void         (* begin_move_drag)      (GdkWindow *window,
-                                        gint       button,
-                                        gint       root_x,
-                                        gint       root_y,
-                                        guint32    timestamp);
+                                         GdkDevice     *device,
+                                         gint       button,
+                                         gint       root_x,
+                                         gint       root_y,
+                                         guint32    timestamp);
   void         (* enable_synchronized_configure) (GdkWindow *window);
   void         (* configure_finished)   (GdkWindow *window);
   void         (* set_opacity)          (GdkWindow *window,
index e9eeefc0cae3c905ee9b8631dfac40586ea88e01..1ff816efdd025f45dca35ab947225d61311f8f93 100644 (file)
@@ -3953,6 +3953,7 @@ gdk_window_x11_set_static_gravities (GdkWindow *window,
 static void
 wmspec_moveresize (GdkWindow *window,
                    gint       direction,
+                   GdkDevice *device,
                    gint       root_x,
                    gint       root_y,
                    guint32    timestamp)     
@@ -3962,7 +3963,7 @@ wmspec_moveresize (GdkWindow *window,
   XClientMessageEvent xclient;
 
   /* Release passive grab */
-  gdk_device_ungrab (display->core_pointer, timestamp);
+  gdk_device_ungrab (device, timestamp);
 
   memset (&xclient, 0, sizeof (xclient));
   xclient.type = ClientMessage;
@@ -3991,6 +3992,7 @@ struct _MoveResizeData
   GdkWindow *moveresize_emulation_window;
   gboolean is_resize;
   GdkWindowEdge resize_edge;
+  GdkDevice *device;
   gint moveresize_button;
   gint moveresize_x;
   gint moveresize_y;
@@ -4018,6 +4020,7 @@ struct _MoveResizeData
 static void
 wmspec_resize_drag (GdkWindow     *window,
                     GdkWindowEdge  edge,
+                    GdkDevice     *device,
                     gint           button,
                     gint           root_x,
                     gint           root_y,
@@ -4068,7 +4071,7 @@ wmspec_resize_drag (GdkWindow     *window,
       return;
     }
   
-  wmspec_moveresize (window, direction, root_x, root_y, timestamp);
+  wmspec_moveresize (window, direction, device, root_x, root_y, timestamp);
 }
 
 static MoveResizeData *
@@ -4346,7 +4349,7 @@ create_moveresize_window (MoveResizeData *mv_resize,
 
   gdk_window_show (mv_resize->moveresize_emulation_window);
 
-  status = gdk_device_grab (gdk_window_get_display (mv_resize->moveresize_emulation_window)->core_pointer,
+  status = gdk_device_grab (mv_resize->device,
                             mv_resize->moveresize_emulation_window,
                             GDK_OWNERSHIP_NONE,
                             FALSE,
@@ -4440,6 +4443,7 @@ calculate_unmoving_origin (MoveResizeData *mv_resize)
 static void
 emulate_resize_drag (GdkWindow     *window,
                      GdkWindowEdge  edge,
+                     GdkDevice     *device,
                      gint           button,
                      gint           root_x,
                      gint           root_y,
@@ -4450,6 +4454,7 @@ emulate_resize_drag (GdkWindow     *window,
   mv_resize->is_resize = TRUE;
   mv_resize->moveresize_button = button;
   mv_resize->resize_edge = edge;
+  mv_resize->device = device;
   mv_resize->moveresize_x = root_x;
   mv_resize->moveresize_y = root_y;
   mv_resize->moveresize_window = g_object_ref (window);
@@ -4469,6 +4474,7 @@ emulate_resize_drag (GdkWindow     *window,
 
 static void
 emulate_move_drag (GdkWindow     *window,
+                   GdkDevice     *device,
                    gint           button,
                    gint           root_x,
                    gint           root_y,
@@ -4477,6 +4483,7 @@ emulate_move_drag (GdkWindow     *window,
   MoveResizeData *mv_resize = get_move_resize_data (GDK_WINDOW_DISPLAY (window), TRUE);
   
   mv_resize->is_resize = FALSE;
+  mv_resize->device = device;
   mv_resize->moveresize_button = button;
   mv_resize->moveresize_x = root_x;
   mv_resize->moveresize_y = root_y;
@@ -4490,11 +4497,12 @@ emulate_move_drag (GdkWindow     *window,
 
 static void
 gdk_x11_window_begin_resize_drag (GdkWindow     *window,
-                                 GdkWindowEdge  edge,
-                                 gint           button,
-                                 gint           root_x,
-                                 gint           root_y,
-                                 guint32        timestamp)
+                                  GdkWindowEdge  edge,
+                                  GdkDevice     *device,
+                                  gint           button,
+                                  gint           root_x,
+                                  gint           root_y,
+                                  guint32        timestamp)
 {
   if (GDK_WINDOW_DESTROYED (window) ||
       !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
@@ -4502,13 +4510,14 @@ gdk_x11_window_begin_resize_drag (GdkWindow     *window,
 
   if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
                                           gdk_atom_intern_static_string ("_NET_WM_MOVERESIZE")))
-    wmspec_resize_drag (window, edge, button, root_x, root_y, timestamp);
+    wmspec_resize_drag (window, edge, device, button, root_x, root_y, timestamp);
   else
-    emulate_resize_drag (window, edge, button, root_x, root_y, timestamp);
+    emulate_resize_drag (window, edge, device, button, root_x, root_y, timestamp);
 }
 
 static void
 gdk_x11_window_begin_move_drag (GdkWindow *window,
+                                GdkDevice *device,
                                gint       button,
                                gint       root_x,
                                gint       root_y,
@@ -4520,10 +4529,10 @@ gdk_x11_window_begin_move_drag (GdkWindow *window,
 
   if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),
                                           gdk_atom_intern_static_string ("_NET_WM_MOVERESIZE")))
-    wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE, root_x, root_y,
+    wmspec_moveresize (window, _NET_WM_MOVERESIZE_MOVE, device, root_x, root_y,
                       timestamp);
   else
-    emulate_move_drag (window, button, root_x, root_y, timestamp);
+    emulate_move_drag (window, device, button, root_x, root_y, timestamp);
 }
 
 static void